package com.wgchao.pharmacymg.application.service.impl;

import com.wgchao.pharmacymg.Infrastructure.back.ResultCommon;
import com.wgchao.pharmacymg.application.mapstruct.dto.PhDrugStorageDTO;
import com.wgchao.pharmacymg.application.service.DrugStorageService;
import com.wgchao.pharmacymg.application.vo.DrugStorageSave;
import com.wgchao.pharmacymg.application.mapstruct.mapper.vo.DrugStorageVDMapper;
import com.wgchao.pharmacymg.application.vo.DrugStorageVO;
import com.wgchao.pharmacymg.application.vo.mapper.PhDrugStorageVoMapper;
import com.wgchao.pharmacymg.domain.event.DrugStorageEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName: DrugStorageServiceImpl
 * @author: wgchao
 * @createTime: 2019/11/18 11:01 AM
 * @Description: TODO
 */
@Service
@Transactional
public class DrugStorageServiceImpl implements DrugStorageService {
    @Autowired
    private DrugStorageEvent drugStorageEvent;
    @Autowired
    private DrugStorageVDMapper drugStorageVDMapper;

    @Override
    public ResultCommon<DrugStorageVO> save(DrugStorageSave drugStorageSave) throws Exception {
        PhDrugStorageDTO drugStorageDTO = drugStorageVDMapper.toDTO(drugStorageSave);
        drugStorageDTO = drugStorageEvent.save(drugStorageDTO);
        return ResultCommon.success().setData(drugStorageVDMapper.toVO(drugStorageDTO));
    }
}
